如何在Windows的命令行中创建一个空文件? 您所在的位置:网站首页 cmd 新建 空文件 如何在Windows的命令行中创建一个空文件?

如何在Windows的命令行中创建一个空文件?

2023-08-12 23:44| 来源: 网络整理| 查看: 265

如果没有重定向,吕克·武或埃里克Konstantopoulos 点 出来到:

copy NUL EMptyFile.txt copy /b NUL EmptyFile.txt

“ 如何从批处理文件创建空文本文件? ”(2008年)也指向:

type NUL > EmptyFile.txt # also echo. 2>EmptyFile.txt copy nul file.txt > nul # also in qid's answer below REM. > empty.file fsutil file createnew file.cmd 0 # to create a file on a mapped drive

游牧民族提到一个原始的:

C:\Users\VonC\prog\tests>aaaa > empty_file 'aaaa' is not recognized as an internal or external command, operable program or batch file. C:\Users\VonC\prog\tests>dir Folder C:\Users\VonC\prog\tests 27/11/2013 10:40 . 27/11/2013 10:40 .. 27/11/2013 10:40 0 empty_file

本着同样的精神,塞缪尔在评论中建议:

我使用的最短的基本上是Nomad的一种:

.>out.txt

它确实给出了一个错误:

'.' is not recognized as an internal or external command

但是此错误在stderr上。并且>仅重定向stdout,而没有产生任何结果。 因此,创建一个空文件。错误消息可以在这里忽略。

(原始答案,2009年11月)

echo.>filename

(echo ""实际上会在文件中添加“”!如果echo没有'。',则会Command ECHO activated在文件中添加“ ...”。)

注意:结果文件不为空,但包含一个返回行序列:2个字节。

此讨论指向一个真正的空文件的真正的批处理解决方案:

filename dir filename 11/09/2009 19:45 0 filename 1 file(s) 0 bytes

“ filename(在Patrick Cuff的答案中提到,并且还会产生一个0字节长的文件),这种“重定向的位”(out.txt dir out.txt

该dir命令应将文件大小指示为11个字节:“ helloworld!”。



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有